﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using System.Data;

namespace Lamex.mMaterial.UI
{
    public partial class FrmMC_XtraReport : DevExpress.XtraReports.UI.XtraReport
    {
         
        public FrmMC_XtraReport(DataTable dtData)
        {
            InitializeComponent();

            XtraReport rpt = this;// 建立报表实例
            rpt.DataSource = dtData;//设置报表数据源  
            InitBands(rpt);//添加带区（Bands） 
           // InitDetailsBasedonXRTable(rpt);//用XRTable显示报表 
        }
        public DataSet FillDataset()
        {
            DataSet myDataSet = new DataSet();
            myDataSet.DataSetName = "myDataSet";
            DataTable table = new DataTable("Detail");

            myDataSet.Tables.Add(table);

            table.Columns.Add("Name", typeof(String));
            table.Columns.Add("Address", typeof(String));
            table.Columns.Add("Sex", typeof(String));
            table.Columns.Add("Birthplace", typeof(String));
            table.Columns.Add("Birthday", typeof(String));

            for (int i = 0; i < 50; i++)
            {
                table.Rows.Add(new object[] { i, "辽宁", "女", "辽宁", "1983-XX-XX" });
                table.Rows.Add(new object[] { i, "广东", "男", "辽宁", "1984-10-XX" });
                table.Rows.Add(new object[] { i, "北京", "男", "北京", "1985-XX-XX" });
                table.Rows.Add(new object[] { i, "上海", "女", "湖南", "1984-XX-XX" });
                table.Rows.Add(new object[] { i, "广东", "女", "辽宁", "1985-2-XX" });
            }


            return myDataSet;
        }
        public void InitBands(XtraReport rpt)
        {
            DetailBand detail = new DetailBand();
            PageHeaderBand pageHeader = new PageHeaderBand();
            ReportFooterBand reportFooter = new ReportFooterBand();
            //detail.Height = XRTableCellHeight;
            reportFooter.Height = 380;
            //pageHeader.Height = XRTableCellHeight;

            rpt.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] { detail, pageHeader, reportFooter });
        }
    }
}
